﻿var $LawRegulationListTable = {
    DealUrl: function (vueApp, url, type, param) {
        switch (url) {
            //加载界面获得List数据
            //从前台走GetList方法,方法中通过url跳转至此处【查询/遍历方法】
            case '/api/LawRegulationListAdministration/GetList': Mock.mock(host + url, type, function (options) {
                if ($LawRegulationListTable.Arrays.length == 0) {
                    //调用下方方法,实现GetList方法
                    $LawRegulationListTable.InitArray();
                    for (var j = 0; j < $LawRegulationListTable.Arrays.length; j++) {
                        if ($LawRegulationListTable.Arrays[j].FitSituation == "符合" && $LawRegulationListTable.Arrays[j].FitSituationOrNotDescribe == "") {
                            $LawRegulationListTable.Arrays[j].FitSituationOrNotDescribe = randomValue('109')
                        }
                        else {
                            $LawRegulationListTable.Arrays[j].FitSituationOrNotDescribe = randomValue('110')
                        }
                    }
                }
                console.log($LawRegulationListTable.Arrays)
                //*****查询条件******//
                //获取界面中JSON所传值
                var p = JSON.parse(options.body);
                //序号
                var FileLeve = getDicValue("65", p.model.FileLeve);
                //分页条件[从第几条取几个数据]
                var offset = p.offset;
                var limit = p.limit;
                var limitArrays2 = [];
                for (var i = 0; i < $LawRegulationListTable.Arrays.length; i++) {
                    var LRList = $LawRegulationListTable.Arrays[i];
                    if (FileLeve && LRList.FileLeve.indexOf(FileLeve) == -1)
                        continue;
                    LRList.FileLeve = getDicValue("65", LRList.FileLeve) == '' ? LRList.FileLeve : getDicValue("65", LRList.FileLeve);
                    //将数据传到数组中
                    limitArrays2.push(LRList);
                }
                var limitArrays = [];
                //console.log(limitArrays2.length);
                for (var i = 0; i < limitArrays2.length; i++) {
                    if (i < offset + limit && i >= offset) {
                        limitArrays.push(limitArrays2[i]);
                    }
                }
                return {
                    result: "Success", message: null,
                    data: { pageData: limitArrays, rowCount: limitArrays2.length },
                };
            }); break;
            //删除方法
            case '/api/LawRegulationListAdministration/DeleteMuti': Mock.mock(host + url, type, function (options) {
                var delIDs = options.body;
                var temp = [];
                for (var i = 0; i < $LawRegulationListTable.Arrays.length; i++) {
                    temp.push($LawRegulationListTable.Arrays[i]);
                }

                for (var i = 0; i < temp.length; i++) {
                    if (delIDs.includes(temp[i].id)) {
                        console.log(temp[i].id);
                        $LawRegulationListTable.Arrays.splice(temp[i], 1);
                    }
                }

                return { result: "Success", message: null, data: null };
            }); break;
            //添加和修改方法
            case '/api/LawRegulationListAdministration/Save': Mock.mock(host + url, type, function (options) {
                var thisentity = JSON.parse(options.body);
                var thisArrays = parent.$LawRegulationListTable.Arrays;
                var cz = true;
                for (var i = 0; i < thisArrays.length; i++) {
                    //按自己实际的去修改内容
                    if (thisArrays[i].id == thisentity.id) {
                        thisArrays[i].FileLeve = thisentity.FileLeve;
                        thisArrays[i].LawRegulationsName = thisentity.LawRegulationsName;
                        thisArrays[i].IssueSubject = thisentity.IssueSubject;
                        thisArrays[i].ApplyClause = thisentity.ApplyClause;
                        thisArrays[i].Symbol = thisentity.Symbol;
                        thisArrays[i].IssueDate = thisentity.IssueDate;
                        thisArrays[i].ImplementationDate = thisentity.ImplementationDate;
                        thisArrays[i].DescribeForWork = thisentity.DescribeForWork;
                        //thisArrays[i].IssueDate = thisentity.IssueDate;//附件
                        thisArrays[i].Remarks = thisentity.Remarks;
                        thisArrays[i].BelongToClass = thisentity.BelongToClass;
                        thisArrays[i].SpecificImplement = thisentity.SpecificImplement;
                        thisArrays[i].Understand = thisentity.Understand;
                        cz = false;
                        break;
                    }
                }
                if (cz) {
                    //Input 页面需要 去操作List页面的数组 parent
                    //按自己实际的去添加内容s
                    var Lawid = thisArrays.length + 1;
                    parent.$LawRegulationListTable.Arrays.push({
                        id: Lawid,
                        FileLeve: thisentity.FileLeve,
                        LawRegulationsName: thisentity.LawRegulationsName,
                        IssueSubject: thisentity.IssueSubject,
                        ApplyClause: thisentity.ApplyClause,
                        Symbol: thisentity.Symbol,
                        IssueDate: thisentity.IssueDate,
                        ImplementationDate: thisentity.ImplementationDate,
                        DescribeForWork: thisentity.DescribeForWork,
                        Remarks: thisentity.Remarks,
                        BelongToClass: thisentity.BelongToClass,
                        SpecificImplement: thisentity.SpecificImplement,
                        Understand: thisentity.Understand
                    });

                }
                return { result: "Success", message: null, data: null };
            }); break;
            //修改方法
            case '/api/LawRegulationListAdministration/get': Mock.mock(host + url + '?' + param, type, function (options) {
                var myArrays = parent.$LawRegulationListTable.Arrays;
                myarray = {};
                for (var i = 0; i < myArrays.length; i++) {
                    if (myArrays[i].id == vueApp.id) {
                        myarray = myArrays[i];
                        break;
                    }
                }
                return {
                    result: "Success", message: null, data: myarray
                };
            }); break;
        }
    },
    //定义数组Arrays
    Arrays: [],
    //定义所抽取的随机函数
    InitArray: function () {
        for (var i = 0; i < 20; i++) {
            //注意  随机数据初始都是随机姓名，需要自己手动调整
            var n = i;//控制统一序号用
            $LawRegulationListTable.Arrays.push(Mock.mock({
                //********************************************
                ////随机时间
                //ChangeTime: Mock.Random.date(),
                ////随机从1-20
                //Lawid: Mock.Random.increment(),
                ////随机Code中定义好的数字
                //FileLeve: randomValue('65'),
                ////随机名字
                //Remarks: Mock.Random.cname(),
                ////随机从1-20
                //ApplyClause: Mock.mock('@range(20)'),
                //********************************************
                //序号
                id: Mock.Random.increment(),
                //文件级别
                FileLeve: randomValue('65'),
                //法律法规名称
                LawRegulationsName: randomValue('66'),
                //发布主体
                IssueSubject: randomValue('67'),
                //文号/标准号
                Symbol: randomValue('68'),
                //颁布日期
                IssueDate: Mock.Random.date(),
                //实施日期
                ImplementationDate: Mock.Random.date(),
                //部门
                Class: randomValue('111'),
                //掌握程度
                MasterLeve: randomValue('112'),
                //符合情况--符合/不符合
                FitSituation: randomValue('108'),
                //(不)/符合情况描述
                FitSituationOrNotDescribe: '',
                //备注
                Remarks: Mock.Random.cname()
            }));
        }
    },
    RandomName: function (FitSituationName) {
        if (FitSituationName == "符合") {
            $LawRegulationListTable.Arrays.push(Mock.mock({

            }));
        }
        else {
            $LawRegulationListTable.Arrays.push(Mock.mock({

            }));
        }
    }
};

var $JobSafetyAnalysisList = {
    DealUrl: function (vueApp, url, type, param) {
        switch (url) {
            //添加和修改方法--/api/JobLicenseApp/get
            case '/api/JobLicenseApp/Save': Mock.mock(host + url, type, function (options) {
                var thisentity = JSON.parse(options.body);
                var thisArrays = parent.$LawRegulationListTable.Arrays;
                var cz = true;
                for (var i = 0; i < thisArrays.length; i++) {
                    //按自己实际的去修改内容
                    if (thisArrays[i].ApplicationNumberValue == thisentity.ApplicationNumberValue) {
                        //作业部门
                        thisArrays[i].UseUnitValue = thisentity.UseUnitValue;
                        //时间
                        thisArrays[i].ApplicationTime = thisentity.ApplicationTime;
                        //No
                        //thisArrays[i].ApplicationNumberValue = thisentity.ApplicationNumberValue;
                        //表格申请日期
                        thisArrays[i].ApplicationTime = thisentity.ApplicationTime;
                        //作业负责人
                        thisArrays[i].JobManagere = thisentity.JobManagere;
                        //工作描述
                        thisArrays[i].WorkDescription = thisentity.WorkDescription;
                        //要求和建议的个人防护用具
                        thisArrays[i].PersonalProtectiveEquipment = thisentity.PersonalProtectiveEquipment;
                        //风险识别表格--作业步骤
                        thisArrays[i].WorkProcedure = thisentity.WorkProcedure;
                        //风险识别
                        thisArrays[i].RiskDiscern = thisentity.RiskDiscern;
                        //安全措施实施方法
                        thisArrays[i].SafetyStep = thisentity.SafetyStep;
                        //单位
                        thisArrays[i].Unit = thisentity.Unit; 
                        //JSA分析人
                        thisArrays[i].JSPAnalyst = thisentity.JSPAnalyst;
                        //参与JSA参与人签字
                        //JSP单位
                        thisArrays[i].JSPUnit = thisentity.JSPUnit;
                        //JSP分析人
                        thisArrays[i].JSPAnalyst = thisentity.JSPAnalyst;
                        //JSP参与签字人签名
                        thisArrays[i].SignName = thisentity.SignName;
                        //JSP参与签字时间
                        thisArrays[i].SignDate = thisentity.SignDate;
                        //没有参与JSP分析的工作人员
                        thisArrays[i].NotJoinJSAPerson = thisentity.NotJoinJSAPerson;
                        //审批人
                        thisArrays[i].Approval = thisentity.Approval;
                        cz = false;
                        break;
                    }
                }
                if (cz) {
                    //Input 页面需要 去操作List页面的数组 parent
                    //按自己实际的去添加内容s
                    //var Lawid = thisArrays.length + 1;
                    parent.$LawRegulationListTable.Arrays.push({
                        //id: Lawid,
                        UseUnitValue: thisentity.UseUnitValue,
                        ApplicationTime: thisentity.ApplicationTime,
                        JobManagere: thisentity.JobManagere,
                        WorkDescription: thisentity.WorkDescription,
                        PersonalProtectiveEquipment: thisentity.PersonalProtectiveEquipment,
                        WorkProcedure: thisentity.WorkProcedure,
                        RiskDiscern: thisentity.RiskDiscern,
                        SafetyStep: thisentity.SafetyStep,
                        Unit: thisentity.Unit,
                        JSPAnalyst: thisentity.JSPAnalyst,
                        SignName: thisentity.SignName,
                        SignDate: thisentity.SignDate,
                        NotJoinJSAPerson: thisentity.NotJoinJSAPerson,
                        Approval: thisentity.Approval,
                    });

                }
                return { result: "Success", message: null, data: null };
            }); break;
            //获取数据
            case '/api/JobLicenseApp/get': Mock.mock(host + url + '?' + param, type, function (options) {
                var myArrays = parent.$JobSafetyAnalysisList.Arrays;
                myarray = {};
                for (var i = 0; i < myArrays.length; i++) {
                    if (myArrays[i].id == vueApp.id) {
                        myarray = myArrays[i];
                        break;
                    }
                }
                return {
                    result: "Success", message: null, data: myarray
                };
            }); break;

        }
    }
};
var $GeneralLiftingWorkDetailed = {
    DealUrl: function (vueApp, url, type, param) {
        switch (url) {
            //获取Input数据
            case '/api/GeneralLiftingWorkDetailed/get': Mock.mock(host + url + '?' + param, type, function (options) {
                var myUsers = parent.$GeneralLiftingWorkDetailed.EquipmenFacilities;
                myuser = {};
                var bool = true;
                for (var i = 0; i < myUsers.length; i++) {
                    if (myUsers[i].id == vueApp.id) {
                        myuser = myUsers[i];
                        bool = false
                        break;
                    }
                }
                //新增
                if (bool) {
                    myuser.ApplicationNumber = Mock.mock('@natural()');

                    myuser.HazardIdentification = HazardIdentificationA();
                    //控制要求数据
                    myuser.BaseDataBaseControlAsk = ControlAsk();
                    myuser.RelatedForm = RelatedFormAdd();//相关表格
                    myuser.Approver = [];//审批人
                    myuser.LiftingOperator = [];
                    myuser.HoistingGuardian = [];
                }
                return {
                    result: "Success", message: null, data: myuser
                };
            }); break;

        }
    },
    EquipmenFacilities: [],
    InitArray: function () {
        for (var i = 0; i < 30; i++) {
            $GeneralLiftingWorkSafety.EquipmenFacilities.push(Mock.mock({
                id: Mock.Random.id(),
                OperatingUnit: randomValue("08"),//作业单位
                ApplicationNumber: Mock.mock('@natural()'),//申请编号
                ApplicationTime: Mock.mock('@date()'),//申请时间
                OperatingName: Mock.Random.cname(),//"作业名称",
                JobManagere: Mock.Random.cname(),//作业负责人
                JobLocation: Mock.mock('@cparagraph(1, 1)'),//作业地点
                JobStartTime: Mock.Random.datetime(),//作业起始时间
                JobEndTime: Mock.Random.datetime(),//有效截至时间
                TerritorialDepartment: randomValue("14"),//属地部门
                CurrentJob: randomValue("18"),//当前作业
                Level: randomValue("03"),//等级
                HoistingPersonnel: Mock.mock('@natural()'),//吊装人员及特殊工种作业证号
                HoistingCommander: Mock.mock('@natural()'),//吊装指挥人及特殊工种作业证号
                LiftingContentDescription: Mock.mock('@natural()'),//吊装内容描述
                CraneRatedLoad: i,//起重机额定载荷
                MaximumWeightObject: i,//被吊物最大重量
                IsDevelopSafetyPlan: randomValue("50"),//是否已制定吊装作业安全方案
                LiftingToolName: Mock.mock('@cparagraph(1, 1)'),//吊装工具名称
                InvolvingOtherSpecialOperations: Mock.mock('@cparagraph(1, 1)'),//涉及其他特殊作业
                contractor: randomValue("12"),//承包商
                HazardIdentification: HazardIdentification(),//危害辨识
                BasedDatabaseManagementRequirements: BasedDatabaseManagementRequirements(),//基于数据库管控要求
                Approver: [{ ApproverUnit: randomValue("08"), ApproverConfirmor: randomValue("09") }],//审批人
                LiftingOperator: [{ LiftingUnit: randomValue("08"), LiftingConfirmor: randomValue("09") }],//吊装作业人
                HoistingGuardian: [{ HoistingUnit: randomValue("08"), HoistingConfirmor: randomValue("09") }],//吊装监护人
                RelatedForm: RelatedForm(),//相关表格

            }));
        }
    },
};
//简易作业吊装安全许可
var $EasyHomeworkList = {
    DealUrl: function (vueApp, url, type, param) {
        switch (url) {
            //获取Input数据
            case '/api/EasyHoistingHomeworkSafeLicence/get': Mock.mock(host + url + '?' + param, type, function (options) {
                var myUsers = parent.$GeneralLiftingWorkDetailed.EquipmenFacilities;
                myuser = {};
                var bool = true;
                for (var i = 0; i < myUsers.length; i++) {
                    if (myUsers[i].id == vueApp.id) {
                        myuser = myUsers[i];
                        bool = false
                        break;
                    }
                }
                //新增
                if (bool) {
                    myuser.ApplicationNumber = Mock.mock('@natural()');
                    //控制要求数据
                    myuser.EasyHoistingHomeworkDate = EasyHomework();
                    myuser.HazardIdentification = HazardIdentificationA();
                    myuser.RelatedForm = RelatedFormAdd();//相关表格
                    myuser.Approver = [];//审批人
                    myuser.LiftingOperator = [];
                    myuser.HoistingGuardian = [];
                }
                return {
                    result: "Success", message: null, data: myuser
                };
            }); break;

        }
    },
    EquipmenFacilities: [],
    InitArray: function () {
        for (var i = 0; i < 30; i++) {
            $GeneralLiftingWorkSafety.EquipmenFacilities.push(Mock.mock({
                id: Mock.Random.id(),
                OperatingUnit: randomValue("08"),//作业单位
                ApplicationNumber: Mock.mock('@natural()'),//申请编号
                ApplicationTime: Mock.mock('@date()'),//申请时间
                OperatingName: Mock.Random.cname(),//"作业名称",
                JobManagere: Mock.Random.cname(),//作业负责人
                JobLocation: Mock.mock('@cparagraph(1, 1)'),//作业地点
                JobStartTime: Mock.Random.datetime(),//作业起始时间
                JobEndTime: Mock.Random.datetime(),//有效截至时间
                TerritorialDepartment: randomValue("14"),//属地部门
                CurrentJob: randomValue("18"),//当前作业
                Level: randomValue("03"),//等级
                HoistingPersonnel: Mock.mock('@natural()'),//吊装人员及特殊工种作业证号
                HoistingCommander: Mock.mock('@natural()'),//吊装指挥人及特殊工种作业证号
                LiftingContentDescription: Mock.mock('@natural()'),//吊装内容描述
                CraneRatedLoad: i,//起重机额定载荷
                MaximumWeightObject: i,//被吊物最大重量
                IsDevelopSafetyPlan: randomValue("50"),//是否已制定吊装作业安全方案
                LiftingToolName: Mock.mock('@cparagraph(1, 1)'),//吊装工具名称
                InvolvingOtherSpecialOperations: Mock.mock('@cparagraph(1, 1)'),//涉及其他特殊作业
                contractor: randomValue("12"),//承包商
                HazardIdentification: HazardIdentification(),//危害辨识
                BasedDatabaseManagementRequirements: BasedDatabaseManagementRequirements(),//基于数据库管控要求
                Approver: [{ ApproverUnit: randomValue("08"), ApproverConfirmor: randomValue("09") }],//审批人
                LiftingOperator: [{ LiftingUnit: randomValue("08"), LiftingConfirmor: randomValue("09") }],//吊装作业人
                HoistingGuardian: [{ HoistingUnit: randomValue("08"), HoistingConfirmor: randomValue("09") }],//吊装监护人
                RelatedForm: RelatedForm(),//相关表格

            }));
        }
    },

};
//遍历安全措施数据
function HazardIdentificationA() {
    var HazardIdentificationList = [];
    for (var i = 0; i < 16; i++) {
        var HazardIdentification = {};
        //var BaseDataBaseControlAsk = {};
        HazardIdentification.SafetyMeasures = getDicValue("92", i);
        HazardIdentification.ImplementationSituation = randomValue('ls1');
        //BaseDataBaseControlAsk.ImplementationSituation = randomValue('ls1');
        HazardIdentificationList.push(HazardIdentification);

    }
    return HazardIdentificationList;
}
//遍历控制要求数据
function ControlAsk() {
    var ControlAskList = [];
    for (var i = 0; i < 2; i++) {
        var BaseDataBaseControlAsk = {};
        BaseDataBaseControlAsk.ControlAsk = getDicValue("kz1", i);
        console.log(BaseDataBaseControlAsk.ControlAsk);
        ControlAskList.push(BaseDataBaseControlAsk);
    }
    return ControlAskList;
}
//遍历简易作业吊装安全许可证
function EasyHomework() {
    var ControlAskList = [];
    for (var i = 0; i < 22; i++) {
        var EasyHoistingHomeworkAsk = {};
        EasyHoistingHomeworkAsk.ControlAsk = getDicValue("jdzy1", i);
        //console.log(BaseDataBaseControlAsk.ControlAsk);
        ControlAskList.push(EasyHoistingHomeworkAsk);
    }
    return ControlAskList;
}